<?php
	class Managethongbao extends CI_Model
    {
        public $ID;
        public $TenThongBao;
        public $NoiDungThongBao;
        public $NgayViet;
        public $HienThi;
        public function __construct() {
            parent::__construct();
            $this->load->database();
        }
        
        public function LoadThongBao($where = null, $reject_id = null, $limit = null, $start = null)
        {
           if($where != null) $this->db->where($where);
           if($limit != '' && $start != '') $this->db->limit($limit, $start);
           $this->db->order_by('ngayviet' , 'desc');
           $query = $this->db->get('thongbao');
           return $query;             
        }
        
        public function ThemThongBaoMoi()
        {            
            $data = array('tenthongbao' => $this->TenThongBao, 
                          'noidungthongbao' => $this->NoiDungThongBao, 
                          'ngayviet' => $this->NgayViet, 
                          'hienthi' => $this->HienThi);
            $result = $this->db->insert('thongbao', $data);
            return $result;
        }
        
        public function CapNhatThongBao($data, $where = null)
        {            
            if($where != null) $this->db->where($where);
            $result = $this->db->update('thongbao', $data);
            return $result;
        }
        
        public function XoaThongBao($where)
        {
          $result =  $this->db->delete('thongbao', $where);
          return $result;
        }
    }
?>